﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A69结构体
{
    class Program
    {
        static void Main(string[] args)
        {
            Float2 f2 = new Float2(0,0);
            Float2 f2A = new Float2(2,3);

            Console.WriteLine(Float2.DistanceFromTo(f2,f2A));
            Console.WriteLine(f2.Distance(f2A)) ;
            
          
        }
    }

    struct Float2
    {
        public float x;
        public float y;
        public Float2(float x,float y)
        {
            this.x = x;
            this.y = y;
        }

        //求两点之间距离的静态方法
        public static float DistanceFromTo(Float2 postion1, Float2 postion2 ) 
        {
            float deltaX = postion1.x - postion2.x;
            float deltaY = postion1.y - postion2.y;

            return  (float)Math.Sqrt(  deltaX* deltaX+deltaY * deltaY);
        }

        //求自己到另一个点距离的方法
        public float Distance(Float2 other) 
        {
           return  DistanceFromTo(this,other);
        }
    }

 




}
